﻿var banner_index=0;//图片下标值
var time;
var banner_ico_now_count=0;//活动按钮当前值
var banner_url="";

function imagePlayer(){
    if(images[banner_index]!=null)
    {           
        APpendBannerIco();
    }
    banner_index++; 
    if(banner_index>=images.length)//循环完一次，重新初始化index
    {
        banner_index=0;
    }
   
   time= setTimeout("imagePlayer()",15000);   
}
//为banner中背景及选中"按钮"一一对应赋值
function APpendBannerIco()
{
    var temp = images.length;     
    if(banner_ico_now_count >= images.length)//活动按钮循环完一次，清空重复加载
    {     
        $("banner_ico").innerHTML="";
    }
    var ul =document.createElement("ul");//加载图片和对应按钮的值
    for(var i = 0;i < images.length;i++)
    {
        temp--;
        var li =document.createElement("li");
        li.style.width="20px";
        li.innerHTML="<img src='/images/imgPlayer_dot.gif' width='12' height='12' style='cursor:pointer;'   onmouseover=\"go("+i+");\"/>";  
        if(i==banner_index)
        {       
            $("banner").style.background="url("+images[temp].imageUrl+")";                
            banner_url=images[temp].linkUrl;
            li.innerHTML="<img src='/images/imgPlayer_active.gif' width='12' height='12' style='cursor:pointer;' onmouseover=\"go("+i+");\"/>";
        }
        ul.appendChild(li);    
         banner_ico_now_count++;    
          $("banner_link").innerHTML="";
           $("banner_link").innerHTML="<a href='"+banner_url+"' target='_blank'><div style='width:510px; height:275px;cursor:pointer;'></div></a>";
    } 
     
     
    var ul_temp = document.createElement("ul");//最初创建顺序为至右往左反向，依次倒序调整。
    var ul_count=ul.childNodes.length;
    var i_temp = ul.childNodes.length;    
    for(var i=0;i< ul_count; i++)
    {
        i_temp--;
         var li_temp =document.createElement("li");
         li_temp= ul.childNodes[i_temp];
        ul_temp.appendChild(li_temp); 
    }    
    
    
    $("banner_ico").appendChild(ul_temp);
}
//点击按钮进行"跳转"图片操作
function go(index)
{
    clearTimeout(time);
    banner_index = index; 
    
    APpendBannerIco();
    
   time= setTimeout("imagePlayer()",15000);   
}

imagePlayer();    

function ChangeImg(now_obj,change_img)
{
    now_obj.src="/images/"+change_img;
}